var gridOptions = {
    // define grid columns
    columnDefs: [
        // using default ColDef
        { headerName: 'Athlete', field: 'athlete', cellClass: 'underline' },
        { headerName: 'Sport', field: 'sport' },
        // using number column type
        {
            headerName: 'Age', field: 'age', type: 'numberColumn',
            checkboxSelection: true, headerCheckboxSelection: true
        },
        { headerName: 'Year', field: 'year', type: 'numberColumn' },
        // using date and non-editable column types
        { headerName: 'Date', field: 'date', width: 200 }
    ],
    defaultColDef: {
        width: 150, filter: 'agTextColumnFilter',

        filterParams: { applyButton: true, clearButton: true, suppressAndOrCondition: false },
    },
    // default ColGroupDef, get applied to every column group
    defaultColGroupDef: {
        marryChildren: true
    },
    columnTypes: {
        numberColumn: { width: 83 }
    },
    rowSelection: 'multiple',
    rowData: null,
    onCellClicked: function (params) {
        console.log(params)
    }, localeText: {
        // for filter panel
        page: 'daPage',
        more: 'daMore',
        to: 'daTo',
        of: 'daOf',
        next: 'daNexten',
        last: 'daLasten',
        first: 'daFirsten',
        previous: 'daPreviousen',
        loadingOoo: 'daLoading...',

        // for set filter
        selectAll: 'daSelect Allen',
        searchOoo: 'daSearch...',
        blanks: 'daBlanc',

        // for number filter and text filter
        filterOoo: 'daFilter...',
        clearFilter: 'daclearFilter...',
        applyFilter: 'daApplyFilter...',
        equals: 'daEquals',
        notEqual: 'daNotEqual',

        // for number filter
        lessThan: 'daLessThan',
        greaterThan: 'daGreaterThan',
        lessThanOrEqual: 'daLessThanOrEqual',
        greaterThanOrEqual: 'daGreaterThanOrEqual',
        inRange: 'daInRange',

        // for text filter
        contains: 'daContains',
        notContains: 'daNotContains',
        startsWith: 'daStarts dawith',
        endsWith: 'daEnds dawith',

        // filter conditions
        andCondition: 'daAND',
        orCondition: 'daOR',

        // the header of the default group column
        group: 'laGroup',

        // tool panel
        columns: 'laColumns',
        filters: 'laFilters',
        rowGroupColumns: 'laPivot Cols',
        rowGroupColumnsEmptyMessage: 'la drag cols to group',
        valueColumns: 'laValue Cols',
        pivotMode: 'laPivot-Mode',
        groups: 'laGroups',
        values: 'laValues',
        pivots: 'laPivots',
        valueColumnsEmptyMessage: 'la drag cols to aggregate',
        pivotColumnsEmptyMessage: 'la drag here to pivot',
        toolPanelButton: 'la tool panel',

        // other
        noRowsToShow: 'la no rows',

        // enterprise menu
        pinColumn: 'laPin Column',
        valueAggregation: 'laValue Agg',
        autosizeThiscolumn: 'laAutosize Diz',
        autosizeAllColumns: 'laAutsoie em All',
        groupBy: 'laGroup by',
        ungroupBy: 'laUnGroup by',
        resetColumns: 'laReset Those Cols',
        expandAll: 'laOpen-em-up',
        collapseAll: 'laClose-em-up',
        toolPanel: 'laTool Panelo',
        export: 'laExporto',
        csvExport: 'laCSV Exportp',
        excelExport: 'laExcel Exporto (.xlsx)',
        excelXmlExport: 'laExcel Exporto (.xml)',

        // enterprise menu (charts)
        chartRange: 'laChart Range',

        columnRangeChart: 'laColumn',
        groupedColumnChart: 'laGrouped',
        stackedColumnChart: 'laStacked',
        normalizedColumnChart: 'la100% Stacked',

        barRangeChart: 'laBar',
        groupedBarChart: 'laGrouped',
        stackedBarChart: 'laStacked',
        normalizedBarChart: 'la100% Stacked',

        lineRangeChart: 'laLine',

        pieRangeChart: 'laPie',
        pieChart: 'laPie',
        doughnutChart: 'laDoughnut',

        areaRangeChart: 'laArea',
        areaChart: 'laArea',
        stackedAreaChart: 'laStacked',
        normalizedAreaChart: 'la100% Stacked',

        // enterprise menu pinning
        pinLeft: 'laPin &lt;&lt;',
        pinRight: 'laPin &gt;&gt;',
        noPin: 'laDontPin &lt;&gt;',

        // enterprise menu aggregation and status bar
        sum: 'laSum',
        min: 'laMin',
        max: 'laMax',
        none: 'laNone',
        count: 'laCount',
        average: 'laAverage',

        // standard menu
        copy: 'laCopy',
        copyWithHeaders: 'laCopy Wit hHeaders',
        ctrlC: 'ctrl n C',
        paste: 'laPaste',
        ctrlV: 'ctrl n V',

        // charts
        settings: 'laSettings',
        data: 'laData',
        format: 'laFormat',
        categories: 'laCategories',
        series: 'laSeries',
        axis: 'laAxis',
        color: 'laColor',
        thickness: 'laThickness',
        xRotation: 'laX Rotation',
        yRotation: 'laY Rotation',
        ticks: 'laTicks',
        width: 'laWidth',
        length: 'laLength',
        padding: 'laPadding',
        chart: 'laChart',
        title: 'laTitle',
        font: 'laFont',
        top: 'laTop',
        right: 'laRight',
        bottom: 'laBottom',
        left: 'laLeft',
        labels: 'laLabels',
        size: 'laSize',
        legend: 'laLegend',
        position: 'laPosition',
        markerSize: 'laMarker Size',
        markerStroke: 'laMarker Stroke',
        markerPadding: 'laMarker Padding',
        itemPaddingX: 'laItem Padding X',
        itemPaddingY: 'laItem Padding Y',
        strokeWidth: 'laStroke Width',
        offset: 'laOffset',
        tooltips: 'laTooltips',
        offsets: 'laOffsets',
        callout: 'laCallout',
        markers: 'laMarkers',
        shadow: 'laShadow',
        blur: 'laBlur',
        xOffset: 'laX Offset',
        yOffset: 'laY Offset',
        lineWidth: 'laLine Width',
        normal: 'laNormal',
        bold: 'laBold',
        italic: 'laItalic',
        boldItalic: 'laBold Italic',
        fillOpacity: 'laFill Opacity',
        strokeOpacity: 'laLine Opacity',
        groupedColumnTooltip: 'laGrouped',
        stackedColumnTooltip: 'laStacked',
        normalizedColumnTooltip: 'la100% Stacked',
        groupedBarTooltip: 'laGrouped',
        stackedBarTooltip: 'laStacked',
        normalizedBarTooltip: 'la100% Stacked',
        pieTooltip: 'laPie',
        doughnutTooltip: 'laDoughnut',
        lineTooltip: 'laLine',
        groupedAreaTooltip: 'laGrouped',
        stackedAreaTooltip: 'laStacked',
        normalizedAreaTooltip: 'la100% Stacked'
    },
};

// setup the grid after the page has finished loading
document.addEventListener('DOMContentLoaded', function () {
    var gridDiv = document.querySelector('#myGrid');
    new agGrid.Grid(gridDiv, gridOptions);

    agGrid.simpleHttpRequest({ url: 'https://raw.githubusercontent.com/ag-grid/ag-grid/master/packages/ag-grid-docs/src/olympicWinnersSmall.json' }).then(function (data) {
        gridOptions.api.setRowData(data);
    });
});

$('#op').click(function () {
    // history.replaceState({state:1},'','/viewer.html?state=1');

    history.back()
})

